import types from '../types.js'
import * as loginInfo from 'src/utils/loginInfo'

export const checkIsLogin = (store) => {
  let now = new Date()
  if (now.getTime() > loginInfo.getExpired() || !loginInfo.getInfo()) {
    loginInfo.removeInfo()
    window.location.href = 'signin.html'
    return
  } else {
    loginInfo.setExpired()
  }
  store.dispatch(types.security.UPDATE_MOBILE, loginInfo.getInfo().mobile)
  store.dispatch(types.security.UPDATE_EMAIL, loginInfo.getInfo().email)
}
